<?php


namespace app\service;


use app\entity\SysRoleMenuEntity;

class SysRoleMenuService
{
    public function saveOrUpdate($roleId, $menuIdList)
    {
        $this->deleteBatch([$roleId]);
        if (!$menuIdList) return ;
        foreach ($menuIdList as $mId) {
            $e = new SysRoleMenuEntity();
            $e->setMenuId($mId);
            $e->setRoleId($roleId);
            $e->save();
        }
    }

    public  function  deleteBatch($roleIds){
        SysRoleMenuEntity::deleteAll(['in', 'role_id', $roleIds]);
        return true;
    }
}